package com.wk.code.wkserver.controller.admin;

import com.wk.code.wkserver.entity.TechType;
import com.wk.code.wkserver.request.admin.TechTypeRequest;
import com.wk.code.wkserver.response.admin.TechTypeResponse;
import com.wk.code.wkserver.response.base.PageInfo;
import com.wk.code.wkserver.response.result.R;
import com.wk.code.wkserver.service.ITechTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import lombok.AllArgsConstructor;

import java.util.List;

/**
 * <p>
 * 技术类别表 前端控制器
 * </p>
 *
 * @author wq
 * @since 2021-08-15
 */
@RestController
@RequestMapping("admin/techType")
@AllArgsConstructor
@Api(tags = "admin-后台技术类型管理")
public class AdminTechTypeController {

    final ITechTypeService techTypeService;


    /**
     * 分页列表
     *
     * @param req 请求参数
     * @return R
     */
    @ApiOperation(value = "分页列表")
    @PostMapping("/page")
    public R<PageInfo<TechType>> page(@RequestBody TechTypeRequest req) {
        return R.success(techTypeService.page(req));
    }

    /**
     * 添加
     *
     * @param req 请求参数
     * @return R
     */
    @ApiOperation(value = "添加")
    @PostMapping("/add")
    public R<Void> add(@RequestBody TechTypeRequest req) {
        techTypeService.add(req);
        return R.success();
    }

    /**
     * 更新
     *
     * @param req req
     * @return R
     */
    @ApiOperation(value = "更新")
    @PostMapping("/update")
    public R<Void> update(@RequestBody TechTypeRequest req) {
        techTypeService.update(req);
        return R.success();
    }

    /**
     * 详情
     *
     * @param id ID
     * @return R
     */
    @ApiOperation(value = "详情")
    @GetMapping("/detail")
    private R<TechType> detail(Integer id) {
        return R.success(techTypeService.detail(id));
    }

    /**
     * 删除
     *
     * @param id ID
     * @return R
     */
    @ApiOperation(value = "删除")
    @GetMapping("/delete")
    private R<Void> delete(Integer id) {
        techTypeService.delete(id);
        return R.success();
    }

    /**
     * 下拉技术类型
     *
     * @return R
     */
    @ApiOperation(value = "下拉技术类型")
    @GetMapping("/listPull")
    public R<List<TechTypeResponse>> listPull() {
        return R.success(techTypeService.listPull());
    }


}
